<?php


namespace LazadaApi\Services;


class LazadaFinanceService extends BaseLazadaService
{
    /**
     * 使用此API获取指定期间内的交易报表
     *
     * @see https://open.lazada.com/doc/api.htm?spm=a2o9m.11193531.0.0.2c3d6bbe6GdZ0B#/api?cid=9&path=/finance/payout/status/get
     *
     * @param string $createdAfter 2018-01-01
     *
     * @return mixed
     * @throws \Exception
     */
    public function getPayoutStatus(string $createdAfter)
    {
        $this->addApiParam('created_after', $createdAfter);

        return $this->get('/finance/payout/status/get');
    }

    /**
     * @param string $startTime 2018-01-01
     * @param string $endTime   2018-01-24
     * @param string $limit     100 The supported maximum number is 500.
     * @param string $offset    0
     * @param string $transType -1
     *
     * @return mixed
     * @throws \Exception
     */
    public function getTransactionDetails(string $startTime, string $endTime, string $limit = '100', string $offset = '0', string $transType = null)
    {
        $this->addApiParam('start_time', $startTime);
        $this->addApiParam('end_time', $endTime);
        if (null !== $transType) {
            $this->addApiParam('trans_type', $transType);
        }
        $this->addApiParam('limit', $limit);
        $this->addApiParam('offset', $offset);

        return $this->get('/finance/transaction/detail/get');
    }
}